/*
package com.itheima.ydd.utils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.ydd.common.ResultData;
import com.itheima.ydd.common.UserHolder;
import com.itheima.ydd.entity.Menu;
import com.itheima.ydd.entity.Role;
import com.itheima.ydd.entity.RoleMenu;
import com.itheima.ydd.entity.User;
import com.itheima.ydd.service.MenuService;
import com.itheima.ydd.service.RoleMenuService;
import com.itheima.ydd.service.RoleService;
import com.itheima.ydd.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.stream.Collectors;
@Configuration
public class RoleUtils {
    @Autowired
    private UserService userService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private RoleMenuService roleMenuService;
    @Autowired
    private MenuService menuService;
    public Boolean Role(String oneRole,String twoRole,String thirdRole){
        LambdaQueryWrapper<Role> roleLambdaQueryWrapper = new LambdaQueryWrapper<>();
        //获取登录人员信息，把test类型转化为string，去掉[]和""
        String userId = UserHolder.getUserId();
        User user2 = userService.getById(userId);
        String strip = StringUtils.strip(user2.getRole_id(), "[]");
        String[] split = strip.split(",");
        for (int i = 0; i < split.length; i++) {
            split[i]=StringUtils.replace(split[i], "\"", "");
        }
        //String replace = StringUtils.replace(strip, "\"", "");
        //String[] split = replace.split(",");
        //注入条件
        roleLambdaQueryWrapper.in(Role::getId,split);
        List<Role> list1 = roleService.list(roleLambdaQueryWrapper);
        //获取id
        List<String> collect = list1.stream().map((item) -> {
            return item.getId();
        }).collect(Collectors.toList());
        //根据权限id去查询是否有用户管理权限
        LambdaQueryWrapper<RoleMenu> roleMenuLambdaQueryWrapper=new LambdaQueryWrapper<>();
        roleMenuLambdaQueryWrapper.in(RoleMenu::getRoleId,collect);
        List<RoleMenu> list = roleMenuService.list(roleMenuLambdaQueryWrapper);
        for (RoleMenu roleMenu : list) {
            String menuId = roleMenu.getMenuId();
            Menu menu = menuService.getById(menuId);
            //一级权限
            if (oneRole.equals(menu.getTitle())){
                LambdaQueryWrapper<Menu> menuLambdaQueryWrapper1=new LambdaQueryWrapper<>();
                menuLambdaQueryWrapper1.eq(Menu::getPid,menuId);
                List<Menu> list3 = menuService.list(menuLambdaQueryWrapper1);
                for (Menu Menu2 : list3) {
                    //二级权限
                    if (twoRole.equals(Menu2.getTitle())) {
                        LambdaQueryWrapper<Menu> menuLambdaQueryWrapper = new LambdaQueryWrapper<>();
                        menuLambdaQueryWrapper.eq(Menu::getPid, Menu2.getId());
                        List<Menu> list2 = menuService.list(menuLambdaQueryWrapper);
                        for (Menu Menu1 : list2) {
                            //Menu menu1 = menuService.getById(Menu1.getId());
                            //三级权限
                            if (thirdRole.equals(Menu1.getTitle())) {
                                //根据用户id删除用户数据
                                return true;
                            }
                        }
                    }
                }
            }
        }
        return false;
    }

}
*/
